#!/bin/bash

#变量
software_dir="Llama-Chinese"

# 安装必要软件
sudo snap install nvtop
sudo apt-get install git-lfs
git lfs install

#下载文件
[ ! -d "$software_dir" ] && git clone https://github.com/LlamaFamily/Llama-Chinese.git $software_dir
cd $software_dir
[ ! -d "amdllama" ] && python3 -m venv amdllama
source amdllama/bin/activate

# 安装依赖
pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/rocm6.0
pip3 install --pre torchtune --extra-index-url https://download.pytorch.org/whl/nightly/rocm --force-reinstall --no-cache-dir
pip3 install -r requirements.txt

# 下载模型
[ ! -d "Llama3-Chinese-8B-Instruct" ] && git clone https://hf-mirror.com/FlagAlpha/Llama3-Chinese-8B-Instruct

sudo sed -i 's@^GRUB_CMDLINE_LINUX="\([^"]*\)"@GRUB_CMDLINE_LINUX="\1 iommu=pt"@' /etc/default/grub
sudo update-grub